package com.mDigitalHealth.http;

import java.util.LinkedHashMap;
import java.util.Map;

import org.json.simple.JSONValue;
import org.json.simple.parser.JSONParser;

public class DigitalHealthUserLoginRequest {
	private String _Transaction_Id;
	private String _Login_Name;
	private String _Login_Password;
	private String _User_Number;

	public DigitalHealthUserLoginRequest() {
		this._Transaction_Id = "";
		this._Login_Name = "";
		this._Login_Password = "";
		this._User_Number = "";
	}

	public DigitalHealthUserLoginRequest(String strTransactionId, String strLoginName,
			String strLoginPassword, String strUserNumber) {
		this._Transaction_Id = strTransactionId;
		this._Login_Name = strLoginName;
		this._Login_Password = strLoginPassword;
		this._User_Number = strUserNumber;
	}

	public void setTransactionId(String strTransactionId) {
		this._Transaction_Id = strTransactionId;
	}

	public String getTransactionId() {
		return this._Transaction_Id;
	}

	public void setLoginName(String strLoginName) {
		this._Login_Name = strLoginName;
	}

	public String getLoginName() {
		return this._Login_Name;
	}

	public void setLoginPassword(String strLoginPassword) {
		this._Login_Password = strLoginPassword;
	}

	public String getLoginPassword() {
		return this._Login_Password;
	}

	public void setUserNumber(String strUserNumber) {
		this._User_Number = strUserNumber;
	}

	public String getUserNumber() {
		return this._User_Number;
	}

	public String encode() {
		try {
			LinkedHashMap map = new LinkedHashMap();

			map.put("Transaction_Id", this._Transaction_Id);
			map.put("Login_Name", this._Login_Name);
			map.put("Login_Password", this._Login_Password);
			map.put("User_Number", this._User_Number);

			return JSONValue.toJSONString(map);
		} catch (Exception e) {
		}
		return null;
	}

	public int decode(String strCode) {
		try {
			if (strCode == null) {
				return -1;
			}
			JSONParser parser = new JSONParser();
			Map map = (Map) parser.parse(strCode);
			this._Transaction_Id = ((String) map.get("Transaction_Id"));
			this._Login_Name = ((String) map.get("Login_Name"));
			this._Login_Password = ((String) map.get("Login_Password"));
			this._User_Number = ((String) map.get("User_Number"));

			return 1;
		} catch (Exception e) {
		}
		return -1;
	}
}
